package com.kll.carolinehmibiz.presentation.presenter

import android.content.Context
import com.kll.carolinehmibiz.OperationManager
import com.kll.carolinehmibiz.model.OperateListener
import com.kll.carolinehmibiz.net.bean.GetCalllogResponse
import com.kll.carolinehmibiz.presentation.BasePresenter
import com.kll.carolinehmibiz.presentation.listener.MyAppointmentProtocol

class MyAppointmentPresenter(context: Context, mView: MyAppointmentProtocol.IView): BasePresenter(context), MyAppointmentProtocol.IPresenter {
    private var mView: MyAppointmentProtocol.IView? = mView
    private var getCalllogIsBusying = false

    override fun getCalllog(isFristPage: Boolean) {
        if (getCalllogIsBusying) return
        getCalllogIsBusying = true
        OperationManager.getInstancce().getCalllog(isFristPage, object : OperateListener {
            override fun onSuccess(state: Int, obj: Any?) {
                getCalllogIsBusying = false
                val data = obj as GetCalllogResponse
                mView?.getCalllogSuccessed(data.list!!)
            }

            override fun onFail(code: Int, message: String) {
                getCalllogIsBusying = false
                mView?.getCalllogFailed(code, message)
            }

        })
    }


}